From: Colin Walters Date: Thu, 1 Dec 2022 13:10:15 +0000 (-0500) Subject: Enable `trust_return_value_nullability` X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2~2^2~19^2~5 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=351d9ffbdc2b0daad813fa6787e1948132bcd620;p=ostree.git Enable `trust_return_value_nullability` Several commonly used APIs currently unnecessarily return `Option`, like `ostree_deployment_get_csum()`. Flip the gir flag for this to on; I think our annotations are correct. --- diff --git a/rust-bindings/conf/ostree.toml b/rust-bindings/conf/ostree.toml index 6bcfe4f7..57314db4 100644 --- a/rust-bindings/conf/ostree.toml +++ b/rust-bindings/conf/ostree.toml @@ -11,6 +11,7 @@ target_path = ".." doc_target_path = "../target/vendor.md" deprecate_by_min_version = true single_version_file = true +trust_return_value_nullability = true generate_display_trait = true girs_directories = [ "../gir-files" ] diff --git a/rust-bindings/src/auto/bootconfig_parser.rs b/rust-bindings/src/auto/bootconfig_parser.rs index 042824c3..0f59255f 100644 --- a/rust-bindings/src/auto/bootconfig_parser.rs +++ b/rust-bindings/src/auto/bootconfig_parser.rs @@ -26,7 +26,7 @@ impl BootconfigParser { #[doc(alias = "ostree_bootconfig_parser_clone")] #[must_use] - pub fn clone(&self) -> Option { + pub fn clone(&self) -> BootconfigParser { unsafe { from_glib_full(ffi::ostree_bootconfig_parser_clone(self.to_glib_none().0)) } diff --git a/rust-bindings/src/auto/collection_ref.rs b/rust-bindings/src/auto/collection_ref.rs index 603b0156..cb3bf409 100644 --- a/rust-bindings/src/auto/collection_ref.rs +++ b/rust-bindings/src/auto/collection_ref.rs @@ -18,7 +18,7 @@ glib::wrapper! { impl CollectionRef { #[doc(alias = "ostree_collection_ref_new")] - pub fn new(collection_id: Option<&str>, ref_name: &str) -> Option { + pub fn new(collection_id: Option<&str>, ref_name: &str) -> CollectionRef { unsafe { from_glib_full(ffi::ostree_collection_ref_new(collection_id.to_glib_none().0, ref_name.to_glib_none().0)) } diff --git a/rust-bindings/src/auto/deployment.rs b/rust-bindings/src/auto/deployment.rs index cba219c3..984bbb25 100644 --- a/rust-bindings/src/auto/deployment.rs +++ b/rust-bindings/src/auto/deployment.rs @@ -28,7 +28,7 @@ impl Deployment { #[doc(alias = "ostree_deployment_clone")] #[must_use] - pub fn clone(&self) -> Option { + pub fn clone(&self) -> Deployment { unsafe { from_glib_full(ffi::ostree_deployment_clone(self.to_glib_none().0)) } @@ -51,7 +51,7 @@ impl Deployment { #[doc(alias = "ostree_deployment_get_bootcsum")] #[doc(alias = "get_bootcsum")] - pub fn bootcsum(&self) -> Option { + pub fn bootcsum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_deployment_get_bootcsum(self.to_glib_none().0)) } @@ -67,7 +67,7 @@ impl Deployment { #[doc(alias = "ostree_deployment_get_csum")] #[doc(alias = "get_csum")] - pub fn csum(&self) -> Option { + pub fn csum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_deployment_get_csum(self.to_glib_none().0)) } @@ -99,7 +99,7 @@ impl Deployment { #[doc(alias = "ostree_deployment_get_origin_relpath")] #[doc(alias = "get_origin_relpath")] - pub fn origin_relpath(&self) -> Option { + pub fn origin_relpath(&self) -> glib::GString { unsafe { from_glib_full(ffi::ostree_deployment_get_origin_relpath(self.to_glib_none().0)) } @@ -107,7 +107,7 @@ impl Deployment { #[doc(alias = "ostree_deployment_get_osname")] #[doc(alias = "get_osname")] - pub fn osname(&self) -> Option { + pub fn osname(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_deployment_get_osname(self.to_glib_none().0)) } @@ -188,7 +188,7 @@ impl Deployment { #[cfg(any(feature = "v2016_4", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))] #[doc(alias = "ostree_deployment_unlocked_state_to_string")] - pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> Option { + pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> glib::GString { unsafe { from_glib_none(ffi::ostree_deployment_unlocked_state_to_string(state.into_glib())) } diff --git a/rust-bindings/src/auto/functions.rs b/rust-bindings/src/auto/functions.rs index 26f9fd5a..9f895217 100644 --- a/rust-bindings/src/auto/functions.rs +++ b/rust-bindings/src/auto/functions.rs @@ -46,14 +46,14 @@ pub fn check_version(required_year: u32, required_release: u32) -> bool { //} #[doc(alias = "ostree_checksum_from_bytes_v")] -pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option { +pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> glib::GString { unsafe { from_glib_full(ffi::ostree_checksum_from_bytes_v(csum_v.to_glib_none().0)) } } #[doc(alias = "ostree_checksum_to_bytes_v")] -pub fn checksum_to_bytes_v(checksum: &str) -> Option { +pub fn checksum_to_bytes_v(checksum: &str) -> glib::Variant { unsafe { from_glib_full(ffi::ostree_checksum_to_bytes_v(checksum.to_glib_none().0)) } @@ -82,7 +82,7 @@ pub fn commit_get_object_sizes(commit_variant: &glib::Variant) -> Result Option { +pub fn commit_get_parent(commit_variant: &glib::Variant) -> glib::GString { unsafe { from_glib_full(ffi::ostree_commit_get_parent(commit_variant.to_glib_none().0)) } @@ -144,7 +144,7 @@ pub fn content_stream_parse(compressed: bool, input: &impl IsA } #[doc(alias = "ostree_create_directory_metadata")] -pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> Option { +pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> glib::Variant { unsafe { from_glib_full(ffi::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.to_glib_none().0)) } @@ -202,7 +202,7 @@ pub fn gpg_error_quark() -> glib::Quark { } #[doc(alias = "ostree_metadata_variant_type")] -pub fn metadata_variant_type(objtype: ObjectType) -> Option { +pub fn metadata_variant_type(objtype: ObjectType) -> glib::VariantType { unsafe { from_glib_none(ffi::ostree_metadata_variant_type(objtype.into_glib())) } @@ -229,14 +229,14 @@ pub fn object_name_deserialize(variant: &glib::Variant) -> (glib::GString, Objec } #[doc(alias = "ostree_object_name_serialize")] -pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> Option { +pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> glib::Variant { unsafe { from_glib_none(ffi::ostree_object_name_serialize(checksum.to_glib_none().0, objtype.into_glib())) } } #[doc(alias = "ostree_object_to_string")] -pub fn object_to_string(checksum: &str, objtype: ObjectType) -> Option { +pub fn object_to_string(checksum: &str, objtype: ObjectType) -> glib::GString { unsafe { from_glib_full(ffi::ostree_object_to_string(checksum.to_glib_none().0, objtype.into_glib())) } @@ -250,7 +250,7 @@ pub fn object_type_from_string(str: &str) -> ObjectType { } #[doc(alias = "ostree_object_type_to_string")] -pub fn object_type_to_string(objtype: ObjectType) -> Option { +pub fn object_type_to_string(objtype: ObjectType) -> glib::GString { unsafe { from_glib_none(ffi::ostree_object_type_to_string(objtype.into_glib())) } diff --git a/rust-bindings/src/auto/gpg_verify_result.rs b/rust-bindings/src/auto/gpg_verify_result.rs index 6748f254..f4c139fc 100644 --- a/rust-bindings/src/auto/gpg_verify_result.rs +++ b/rust-bindings/src/auto/gpg_verify_result.rs @@ -34,13 +34,13 @@ impl GpgVerifyResult { } //#[doc(alias = "ostree_gpg_verify_result_get")] - //pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 29 }) -> Option { + //pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 29 }) -> glib::Variant { // unsafe { TODO: call ffi:ostree_gpg_verify_result_get() } //} #[doc(alias = "ostree_gpg_verify_result_get_all")] #[doc(alias = "get_all")] - pub fn all(&self, signature_index: u32) -> Option { + pub fn all(&self, signature_index: u32) -> glib::Variant { unsafe { from_glib_none(ffi::ostree_gpg_verify_result_get_all(self.to_glib_none().0, signature_index)) } diff --git a/rust-bindings/src/auto/mutable_tree.rs b/rust-bindings/src/auto/mutable_tree.rs index 98206f31..d70941c7 100644 --- a/rust-bindings/src/auto/mutable_tree.rs +++ b/rust-bindings/src/auto/mutable_tree.rs @@ -93,7 +93,7 @@ impl MutableTree { #[doc(alias = "ostree_mutable_tree_get_contents_checksum")] #[doc(alias = "get_contents_checksum")] - pub fn contents_checksum(&self) -> Option { + pub fn contents_checksum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_mutable_tree_get_contents_checksum(self.to_glib_none().0)) } @@ -107,7 +107,7 @@ impl MutableTree { #[doc(alias = "ostree_mutable_tree_get_metadata_checksum")] #[doc(alias = "get_metadata_checksum")] - pub fn metadata_checksum(&self) -> Option { + pub fn metadata_checksum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_mutable_tree_get_metadata_checksum(self.to_glib_none().0)) } diff --git a/rust-bindings/src/auto/remote.rs b/rust-bindings/src/auto/remote.rs index 95939f25..9b80a8c3 100644 --- a/rust-bindings/src/auto/remote.rs +++ b/rust-bindings/src/auto/remote.rs @@ -3,6 +3,7 @@ // DO NOT EDIT use glib::translate::*; +use std::fmt; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -18,7 +19,7 @@ glib::wrapper! { impl Remote { #[doc(alias = "ostree_remote_get_name")] #[doc(alias = "get_name")] - pub fn name(&self) -> Option { + pub fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_remote_get_name(self.to_glib_none().0)) } @@ -26,9 +27,16 @@ impl Remote { #[doc(alias = "ostree_remote_get_url")] #[doc(alias = "get_url")] - pub fn url(&self) -> Option { + pub fn url(&self) -> glib::GString { unsafe { from_glib_full(ffi::ostree_remote_get_url(self.to_glib_none().0)) } } } + +impl fmt::Display for Remote { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&self.name()) + } +} diff --git a/rust-bindings/src/auto/repo.rs b/rust-bindings/src/auto/repo.rs index 58babf96..39bead09 100644 --- a/rust-bindings/src/auto/repo.rs +++ b/rust-bindings/src/auto/repo.rs @@ -161,7 +161,7 @@ impl Repo { } #[doc(alias = "ostree_repo_copy_config")] - pub fn copy_config(&self) -> Option { + pub fn copy_config(&self) -> glib::KeyFile { unsafe { from_glib_full(ffi::ostree_repo_copy_config(self.to_glib_none().0)) } @@ -217,7 +217,7 @@ impl Repo { #[cfg_attr(feature = "dox", doc(cfg(feature = "v2019_2")))] #[doc(alias = "ostree_repo_get_bootloader")] #[doc(alias = "get_bootloader")] - pub fn bootloader(&self) -> Option { + pub fn bootloader(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_repo_get_bootloader(self.to_glib_none().0)) } @@ -235,7 +235,7 @@ impl Repo { #[doc(alias = "ostree_repo_get_config")] #[doc(alias = "get_config")] - pub fn config(&self) -> Option { + pub fn config(&self) -> glib::KeyFile { unsafe { from_glib_none(ffi::ostree_repo_get_config(self.to_glib_none().0)) } @@ -302,7 +302,7 @@ impl Repo { #[doc(alias = "ostree_repo_get_path")] #[doc(alias = "get_path")] - pub fn path(&self) -> Option { + pub fn path(&self) -> gio::File { unsafe { from_glib_none(ffi::ostree_repo_get_path(self.to_glib_none().0)) } @@ -340,7 +340,7 @@ impl Repo { #[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_5")))] #[doc(alias = "ostree_repo_get_remote_option")] #[doc(alias = "get_remote_option")] - pub fn remote_option(&self, remote_name: &str, option_name: &str, default_value: Option<&str>) -> Result { + pub fn remote_option(&self, remote_name: &str, option_name: &str, default_value: Option<&str>) -> Result, glib::Error> { unsafe { let mut out_value = ptr::null_mut(); let mut error = ptr::null_mut(); @@ -353,7 +353,7 @@ impl Repo { #[cfg(any(feature = "v2020_8", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_8")))] #[doc(alias = "ostree_repo_gpg_sign_data")] - pub fn gpg_sign_data(&self, data: &glib::Bytes, old_signatures: &glib::Bytes, key_id: &[&str], homedir: Option<&str>, cancellable: Option<&impl IsA>) -> Result { + pub fn gpg_sign_data(&self, data: &glib::Bytes, old_signatures: Option<&glib::Bytes>, key_id: &[&str], homedir: Option<&str>, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut out_signatures = ptr::null_mut(); let mut error = ptr::null_mut(); @@ -1001,7 +1001,7 @@ impl Repo { #[cfg(any(feature = "v2021_4", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))] #[doc(alias = "ostree_repo_signature_verify_commit_data")] - pub fn signature_verify_commit_data(&self, remote_name: &str, commit_data: &glib::Bytes, commit_metadata: &glib::Bytes, flags: RepoVerifyFlags) -> Result, glib::Error> { + pub fn signature_verify_commit_data(&self, remote_name: &str, commit_data: &glib::Bytes, commit_metadata: &glib::Bytes, flags: RepoVerifyFlags) -> Result { unsafe { let mut out_results = ptr::null_mut(); let mut error = ptr::null_mut(); diff --git a/rust-bindings/src/auto/repo_file.rs b/rust-bindings/src/auto/repo_file.rs index 3631c3ad..31fe363c 100644 --- a/rust-bindings/src/auto/repo_file.rs +++ b/rust-bindings/src/auto/repo_file.rs @@ -31,7 +31,7 @@ impl RepoFile { #[doc(alias = "ostree_repo_file_get_checksum")] #[doc(alias = "get_checksum")] - pub fn checksum(&self) -> Option { + pub fn checksum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_repo_file_get_checksum(self.to_glib_none().0)) } @@ -39,7 +39,7 @@ impl RepoFile { #[doc(alias = "ostree_repo_file_get_repo")] #[doc(alias = "get_repo")] - pub fn repo(&self) -> Option { + pub fn repo(&self) -> Repo { unsafe { from_glib_none(ffi::ostree_repo_file_get_repo(self.to_glib_none().0)) } @@ -48,7 +48,7 @@ impl RepoFile { #[doc(alias = "ostree_repo_file_get_root")] #[doc(alias = "get_root")] #[must_use] - pub fn root(&self) -> Option { + pub fn root(&self) -> RepoFile { unsafe { from_glib_none(ffi::ostree_repo_file_get_root(self.to_glib_none().0)) } @@ -77,28 +77,28 @@ impl RepoFile { } #[doc(alias = "ostree_repo_file_tree_get_contents")] - pub fn tree_get_contents(&self) -> Option { + pub fn tree_get_contents(&self) -> glib::Variant { unsafe { from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0)) } } #[doc(alias = "ostree_repo_file_tree_get_contents_checksum")] - pub fn tree_get_contents_checksum(&self) -> Option { + pub fn tree_get_contents_checksum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_repo_file_tree_get_contents_checksum(self.to_glib_none().0)) } } #[doc(alias = "ostree_repo_file_tree_get_metadata")] - pub fn tree_get_metadata(&self) -> Option { + pub fn tree_get_metadata(&self) -> glib::Variant { unsafe { from_glib_full(ffi::ostree_repo_file_tree_get_metadata(self.to_glib_none().0)) } } #[doc(alias = "ostree_repo_file_tree_get_metadata_checksum")] - pub fn tree_get_metadata_checksum(&self) -> Option { + pub fn tree_get_metadata_checksum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_repo_file_tree_get_metadata_checksum(self.to_glib_none().0)) } diff --git a/rust-bindings/src/auto/se_policy.rs b/rust-bindings/src/auto/se_policy.rs index 386e5bee..13199326 100644 --- a/rust-bindings/src/auto/se_policy.rs +++ b/rust-bindings/src/auto/se_policy.rs @@ -55,7 +55,7 @@ impl SePolicy { #[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_5")))] #[doc(alias = "ostree_sepolicy_get_csum")] #[doc(alias = "get_csum")] - pub fn csum(&self) -> Option { + pub fn csum(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_sepolicy_get_csum(self.to_glib_none().0)) } @@ -63,7 +63,7 @@ impl SePolicy { #[doc(alias = "ostree_sepolicy_get_label")] #[doc(alias = "get_label")] - pub fn label(&self, relpath: &str, unix_mode: u32, cancellable: Option<&impl IsA>) -> Result { + pub fn label(&self, relpath: &str, unix_mode: u32, cancellable: Option<&impl IsA>) -> Result, glib::Error> { unsafe { let mut out_label = ptr::null_mut(); let mut error = ptr::null_mut(); @@ -75,7 +75,7 @@ impl SePolicy { #[doc(alias = "ostree_sepolicy_get_name")] #[doc(alias = "get_name")] - pub fn name(&self) -> Option { + pub fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_sepolicy_get_name(self.to_glib_none().0)) } @@ -83,14 +83,14 @@ impl SePolicy { #[doc(alias = "ostree_sepolicy_get_path")] #[doc(alias = "get_path")] - pub fn path(&self) -> Option { + pub fn path(&self) -> gio::File { unsafe { from_glib_none(ffi::ostree_sepolicy_get_path(self.to_glib_none().0)) } } #[doc(alias = "ostree_sepolicy_restorecon")] - pub fn restorecon(&self, path: &str, info: Option<&gio::FileInfo>, target: &impl IsA, flags: SePolicyRestoreconFlags, cancellable: Option<&impl IsA>) -> Result { + pub fn restorecon(&self, path: &str, info: Option<&gio::FileInfo>, target: &impl IsA, flags: SePolicyRestoreconFlags, cancellable: Option<&impl IsA>) -> Result, glib::Error> { unsafe { let mut out_new_label = ptr::null_mut(); let mut error = ptr::null_mut(); @@ -116,10 +116,11 @@ impl SePolicy { } } -unsafe impl Send for SePolicy {} - impl fmt::Display for SePolicy { + #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str("SePolicy") + f.write_str(&self.name()) } } + +unsafe impl Send for SePolicy {} diff --git a/rust-bindings/src/auto/sign.rs b/rust-bindings/src/auto/sign.rs index 64b1da6c..90fa1ded 100644 --- a/rust-bindings/src/auto/sign.rs +++ b/rust-bindings/src/auto/sign.rs @@ -85,7 +85,7 @@ pub trait SignExt: 'static { #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] #[doc(alias = "ostree_sign_get_name")] #[doc(alias = "get_name")] - fn name(&self) -> Option; + fn name(&self) -> glib::GString; #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] @@ -95,12 +95,12 @@ pub trait SignExt: 'static { #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] #[doc(alias = "ostree_sign_metadata_format")] - fn metadata_format(&self) -> Option; + fn metadata_format(&self) -> glib::GString; #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] #[doc(alias = "ostree_sign_metadata_key")] - fn metadata_key(&self) -> Option; + fn metadata_key(&self) -> glib::GString; #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] @@ -190,7 +190,7 @@ impl> SignExt for O { #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] - fn name(&self) -> Option { + fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_sign_get_name(self.as_ref().to_glib_none().0)) } @@ -209,7 +209,7 @@ impl> SignExt for O { #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] - fn metadata_format(&self) -> Option { + fn metadata_format(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_sign_metadata_format(self.as_ref().to_glib_none().0)) } @@ -217,7 +217,7 @@ impl> SignExt for O { #[cfg(any(feature = "v2020_2", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))] - fn metadata_key(&self) -> Option { + fn metadata_key(&self) -> glib::GString { unsafe { from_glib_none(ffi::ostree_sign_metadata_key(self.as_ref().to_glib_none().0)) } diff --git a/rust-bindings/src/auto/sysroot.rs b/rust-bindings/src/auto/sysroot.rs index 32d5855e..020a8a1b 100644 --- a/rust-bindings/src/auto/sysroot.rs +++ b/rust-bindings/src/auto/sysroot.rs @@ -185,7 +185,7 @@ impl Sysroot { #[doc(alias = "ostree_sysroot_get_deployment_directory")] #[doc(alias = "get_deployment_directory")] - pub fn deployment_directory(&self, deployment: &Deployment) -> Option { + pub fn deployment_directory(&self, deployment: &Deployment) -> gio::File { unsafe { from_glib_full(ffi::ostree_sysroot_get_deployment_directory(self.to_glib_none().0, deployment.to_glib_none().0)) } @@ -193,7 +193,7 @@ impl Sysroot { #[doc(alias = "ostree_sysroot_get_deployment_dirpath")] #[doc(alias = "get_deployment_dirpath")] - pub fn deployment_dirpath(&self, deployment: &Deployment) -> Option { + pub fn deployment_dirpath(&self, deployment: &Deployment) -> glib::GString { unsafe { from_glib_full(ffi::ostree_sysroot_get_deployment_dirpath(self.to_glib_none().0, deployment.to_glib_none().0)) } @@ -225,7 +225,7 @@ impl Sysroot { #[doc(alias = "ostree_sysroot_get_path")] #[doc(alias = "get_path")] - pub fn path(&self) -> Option { + pub fn path(&self) -> gio::File { unsafe { from_glib_none(ffi::ostree_sysroot_get_path(self.to_glib_none().0)) } @@ -369,7 +369,7 @@ impl Sysroot { } #[doc(alias = "ostree_sysroot_origin_new_from_refspec")] - pub fn origin_new_from_refspec(&self, refspec: &str) -> Option { + pub fn origin_new_from_refspec(&self, refspec: &str) -> glib::KeyFile { unsafe { from_glib_full(ffi::ostree_sysroot_origin_new_from_refspec(self.to_glib_none().0, refspec.to_glib_none().0)) } @@ -400,7 +400,7 @@ impl Sysroot { #[cfg(any(feature = "v2017_7", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))] #[doc(alias = "ostree_sysroot_repo")] - pub fn repo(&self) -> Option { + pub fn repo(&self) -> Repo { unsafe { from_glib_none(ffi::ostree_sysroot_repo(self.to_glib_none().0)) } @@ -534,7 +534,7 @@ impl Sysroot { #[doc(alias = "ostree_sysroot_get_deployment_origin_path")] #[doc(alias = "get_deployment_origin_path")] - pub fn deployment_origin_path(deployment_path: &impl IsA) -> Option { + pub fn deployment_origin_path(deployment_path: &impl IsA) -> gio::File { unsafe { from_glib_full(ffi::ostree_sysroot_get_deployment_origin_path(deployment_path.as_ref().to_glib_none().0)) } diff --git a/rust-bindings/src/auto/versions.txt b/rust-bindings/src/auto/versions.txt index 154f5b03..c9131191 100644 --- a/rust-bindings/src/auto/versions.txt +++ b/rust-bindings/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 0eeebbdf9d4d) -from gir-files (@ be0dbf02d770) +from gir-files (@ f4ba299323ae) diff --git a/rust-bindings/src/collection_ref.rs b/rust-bindings/src/collection_ref.rs index 0fb28deb..47daaaca 100644 --- a/rust-bindings/src/collection_ref.rs +++ b/rust-bindings/src/collection_ref.rs @@ -54,7 +54,7 @@ mod tests { #[test] fn should_get_collection_id() { - let collection_ref = CollectionRef::new(Some("collection.id"), "ref").unwrap(); + let collection_ref = CollectionRef::new(Some("collection.id"), "ref"); let id = collection_ref.collection_id().unwrap().to_str().unwrap(); assert_eq!(id, "collection.id"); @@ -62,7 +62,7 @@ mod tests { #[test] fn should_get_none_collection_id() { - let collection_ref = CollectionRef::new(None, "ref").unwrap(); + let collection_ref = CollectionRef::new(None, "ref"); let id = collection_ref.collection_id(); assert_eq!(id, None); @@ -70,7 +70,7 @@ mod tests { #[test] fn should_get_ref_name() { - let collection_ref = CollectionRef::new(Some("collection.id"), "ref-name").unwrap(); + let collection_ref = CollectionRef::new(Some("collection.id"), "ref-name"); let ref_name = collection_ref.ref_name().to_str().unwrap(); assert_eq!(ref_name, "ref-name"); diff --git a/rust-bindings/src/object_name.rs b/rust-bindings/src/object_name.rs index d6071780..772b0d88 100644 --- a/rust-bindings/src/object_name.rs +++ b/rust-bindings/src/object_name.rs @@ -34,8 +34,7 @@ impl ObjectName { /// Create a new `ObjectName` with the given checksum and `ObjectType`. pub fn new>(checksum: S, object_type: ObjectType) -> ObjectName { let checksum = checksum.into(); - let variant = object_name_serialize(checksum.as_str(), object_type) - .expect("type checks should make this safe"); + let variant = object_name_serialize(checksum.as_str(), object_type); ObjectName { variant, checksum, @@ -56,7 +55,6 @@ impl ObjectName { /// Format this `ObjectName` as a string. fn to_string(&self) -> GString { object_to_string(self.checksum(), self.object_type()) - .expect("type checks should make this safe") } } diff --git a/rust-bindings/src/sysroot.rs b/rust-bindings/src/sysroot.rs index d7b2b767..ea8c3cb1 100644 --- a/rust-bindings/src/sysroot.rs +++ b/rust-bindings/src/sysroot.rs @@ -85,7 +85,7 @@ mod tests { assert_eq!(sysroot.subbootversion(), 0); sysroot.cleanup(gio::Cancellable::NONE).unwrap(); - sysroot.path().unwrap() + sysroot.path() }; let path_loaded = { let tmp_path = Some(tmpdir.path().to_path_buf()); @@ -100,7 +100,7 @@ mod tests { assert_eq!(sysroot.subbootversion(), 0); sysroot.cleanup(gio::Cancellable::NONE).unwrap(); - sysroot.path().unwrap() + sysroot.path() }; assert_eq!(path_created.to_string(), path_loaded.to_string()); } diff --git a/rust-bindings/src/tests/collection_ref.rs b/rust-bindings/src/tests/collection_ref.rs index b6bf050e..515bd385 100644 --- a/rust-bindings/src/tests/collection_ref.rs +++ b/rust-bindings/src/tests/collection_ref.rs @@ -12,68 +12,62 @@ fn hash(v: &impl Hash) -> u64 { #[test] fn same_value_should_be_equal() { - let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); + let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); assert_eq!(r, r); } #[test] fn equal_values_should_be_equal() { - let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); - let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); assert_eq!(a, b); } #[test] fn equal_values_without_collection_id_should_be_equal() { - let a = CollectionRef::new(None, "ref-name").unwrap(); - let b = CollectionRef::new(None, "ref-name").unwrap(); + let a = CollectionRef::new(None, "ref-name"); + let b = CollectionRef::new(None, "ref-name"); assert_eq!(a, b); } #[test] fn different_values_should_not_be_equal() { - let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1").unwrap(); - let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1"); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2"); assert_ne!(a, b); } -#[test] -fn new_with_invalid_collection_id_should_return_none() { - let r = CollectionRef::new(Some(".abc"), "ref"); - assert_eq!(r, None); -} - #[test] fn hash_for_equal_values_should_be_equal() { - let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); - let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); assert_eq!(hash(&a), hash(&b)); } #[test] fn hash_for_values_with_different_collection_id_should_be_different() { - let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref").unwrap(); - let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref"); + let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref"); assert_ne!(hash(&a), hash(&b)); } #[test] fn hash_for_values_with_different_ref_id_should_be_different() { - let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1").unwrap(); - let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1"); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2"); assert_ne!(hash(&a), hash(&b)); } #[test] fn hash_should_be_different_if_collection_id_is_absent() { - let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); - let b = CollectionRef::new(None, "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); + let b = CollectionRef::new(None, "ref"); assert_ne!(hash(&a), hash(&b)); } #[test] fn clone_should_be_equal_to_original_value() { - let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref"); let b = a.clone(); assert_eq!(a, b); } diff --git a/rust-bindings/sys/src/auto/versions.txt b/rust-bindings/sys/src/auto/versions.txt index 154f5b03..c9131191 100644 --- a/rust-bindings/sys/src/auto/versions.txt +++ b/rust-bindings/sys/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 0eeebbdf9d4d) -from gir-files (@ be0dbf02d770) +from gir-files (@ f4ba299323ae) diff --git a/rust-bindings/sys/src/lib.rs b/rust-bindings/sys/src/lib.rs index d6e576d2..fe17c5d5 100644 --- a/rust-bindings/sys/src/lib.rs +++ b/rust-bindings/sys/src/lib.rs @@ -1255,21 +1255,21 @@ extern "C" { pub fn ostree_collection_ref_dup(ref_: *const OstreeCollectionRef) -> *mut OstreeCollectionRef; #[cfg(any(feature = "v2018_6", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] + pub fn ostree_collection_ref_equal(ref1: gconstpointer, ref2: gconstpointer) -> gboolean; + #[cfg(any(feature = "v2018_6", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] pub fn ostree_collection_ref_free(ref_: *mut OstreeCollectionRef); #[cfg(any(feature = "v2018_6", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] + pub fn ostree_collection_ref_hash(ref_: gconstpointer) -> c_uint; + #[cfg(any(feature = "v2018_6", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] pub fn ostree_collection_ref_dupv( refs: *const *const OstreeCollectionRef, ) -> *mut *mut OstreeCollectionRef; #[cfg(any(feature = "v2018_6", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] - pub fn ostree_collection_ref_equal(ref1: gconstpointer, ref2: gconstpointer) -> gboolean; - #[cfg(any(feature = "v2018_6", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] pub fn ostree_collection_ref_freev(refs: *mut *mut OstreeCollectionRef); - #[cfg(any(feature = "v2018_6", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))] - pub fn ostree_collection_ref_hash(ref_: gconstpointer) -> c_uint; //========================================================================= // OstreeCommitSizesEntry diff --git a/rust-bindings/tests/sign/mod.rs b/rust-bindings/tests/sign/mod.rs index aa2a59a0..745076cb 100644 --- a/rust-bindings/tests/sign/mod.rs +++ b/rust-bindings/tests/sign/mod.rs @@ -8,7 +8,7 @@ use ostree::{gio, glib}; #[test] fn sign_api_should_work() { let dummy_sign = ostree::Sign::by_name("dummy").unwrap(); - assert_eq!(dummy_sign.name().unwrap(), "dummy"); + assert_eq!(dummy_sign.name(), "dummy"); let result = ostree::prelude::SignExt::data( &dummy_sign, @@ -25,7 +25,7 @@ fn sign_api_should_work() { } fn inner_sign_ed25519(signer: T) { - assert_eq!(signer.name().unwrap(), "ed25519"); + assert_eq!(signer.name(), "ed25519"); let td = tempfile::tempdir().unwrap(); let path = td.path();